<?php

// +----------------------------------------------------------------------
// | 功能说明"
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2030 http://www.jmzh1688.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: lxl
// +----------------------------------------------------------------------

namespace app\test\controller;

use think\Controller;
use think\Db;



class Base extends Controller
{

    public function _initialize()
    {

     
    }


    function __construct() {
        parent::__construct();
    }


    function loadclass()
    {
       
        $tablename = input("get.tablename");
        $flag = input("get.flag");
        $level = input("get.level");
        $valuename = input("get.valuename");
        $parentid = input("get.parentid");

        if($tablename==""){$tablename="sys_dic";}



        $where=[];
        if($flag!=null)
        {
        	$where["flag"]=$flag;
        }
        if($level!=0)
        {
        		$where["level"]=$level;
        		$where["parentid"]=$parentid;
        }
     
     

      
         $list=  Db::name($tablename)->where($where)->select();
       
         if(!array_key_exists("name",$list[0])&&!array_key_exists("title",$list[0]))
         {
         	  $keys=[];foreach ($list[0] as $key => $valuse){$keys[] = $key;} $mykey=$keys[1];
         	 
       
         	for($p=0;$p<count($list);$p++)
         	{
         		$list[$p]["name"]=$list[$p][$mykey];
         	}
         }
       
       
       return json($list);
    }
    


}
